package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.Schedule;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ScheduleVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "内容")
    private String content;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "创建人用户id")
    private Integer createAdminId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "提醒状态：0不提醒 1提醒")
    private Integer eventType;

    @ApiModelProperty(value = "参与人用户id")
    private String ownerAdminIds;

    @ApiModelProperty(value = "地点")
    private String address;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "提醒时间：0准时提醒1：5分钟前2：15分钟前3：30分钟前4：一个小时前5：两个小时前6：一天前7：两天前8：一周前")
    private Integer remindType;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Schedule convert(ScheduleVO vo) {
        Schedule entity = new Schedule();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Schedule> convertList(List<ScheduleVO> list) {
        List<Schedule> resultList = new ArrayList<>();
        for (ScheduleVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
